Repository navigation
Deny Bash writes to memory files unless the command only reads - #58
Merged
Merged
Conversation
- Gate any Bash command naming a memories path, including a symlinked dir's target, not only deletes - Match memory paths instead of the bare word, so read-only commands mentioning it pass - Drop the shared-memories layout from tests and document the rule in CLAUDE.md
- Match the resolved memories dir with escapeRegExp and under() instead of a hand-rolled scan - Skip symlink resolution when the command already names .claude/memories - Key deny reasons by kind and drop a duplicated sub-agent assertion
bguidolim
force-pushed
the
bruno/kb-gate-bash-memory-writes
branch
from
October 31, 2026 23:47
7346806 to
00eb670
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The memory gate checked Bash only for deletes, so a session could rewrite a memory with a heredoc script, a redirect or
sed -iand skip the continuous-learning checks that a file-tool edit is held to. It also matched the bare word "memories", which denied harmless reads such as a grep whose pattern mentioned it.Now any Bash command that names a memory path, including the real directory behind a symlinked one, is denied unless every part of it is a plain read. This holds even while a memory skill is active, since memory edits belong to Edit and Write. Deletes still need memory-audit. The per-turn budget still lets a misjudged read through.
Test plan
mcs sync, then in a session runecho x > .claude/memories/tmp.md→ expect a denial pointing to Edit/Writecatorgrepon a memory file → expect it to rungit commit -m "…memories…"→ expect no denial